<template>
    <div class="modal" v-if="props.visible">
        <div class="modal-content">
            <div class="modal-header">{{ props.title }}</div>
            <div class="modal-body">
                <div>{{ props.content }}</div>
                <slot></slot>
            </div>
            <Footer @cancel="onCancel" @confirm="onConfirm"></Footer>
        </div>
    </div>
</template>
<script setup>
import Footer from './Footer.vue'

let props = defineProps({
    visible: {
        type: Boolean,
        default: false
    },
    title: {
        type: String,
        default: ''
    },
    content: {
        type: String,
        default: ''
    },
    close: {
        type: Function,
        default: null
    }
})

// emit
const emit = defineEmits(['update:visible', 'handleConfirm'])
const onCancel = () => {
    emit("update:visible", false)
}

const onConfirm = () => {
    props.close()
}
</script>
<style>
.modal {
    background-color: #999999;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #ffffff;
    min-width: 400px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-radius: 5px;
    z-index: 2000;
}

.modal-header {
    font-size: 18px;
}

.modal-header,
.modal-body {
    border-bottom: 1px solid #eeeeee;
    text-align: left;
}

.modal-body {
    flex-grow: 1;
}

.modal-footer {
    text-align: right;
}

.modal-header,
.modal-body,
.modal-footer {
    padding: 15px 20px;
}

.modal-footer button {
    padding: 5px 15px;
    margin-left: 10px;
    font-size: 14px;
}
</style>